import { getMsbdData, addMsbdData, updateMsbdData, delMsbdData } from '../utils/axios/msbdApi.js'

export const state = () => {
    return {
        msbdTableData: [],
        classify: [],
    }
}
export const mutations = {
    SET_MSBD_TABLE_DATA(state, data) {
        state.msbdTableData = data.data
        state.classify = data.classify
    },


}
export const actions = {
    async renderMsbdTable({ commit }) {
        let { data } = await getMsbdData();
        commit("SET_MSBD_TABLE_DATA", data.data)
    },
    async saveMsbdData({ dispatch }, form) {
        await addMsbdData({ ...form, author: "situ", cid: 1 })
        dispatch("renderMsbdTable")
    },
    async delteMsbdData({ dispatch }, row) {
        await delMsbdData(row)
        // console.log(data);
        dispatch("renderMsbdTable")
    },
    async updateMsbdData({ dispatch }, form) {
        await updateMsbdData({ ...form, author: form.author, cid: 1 })
        dispatch("renderMsbdTable")
    }

}
export const getters = {

}